home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
pibt40s2.arc
/
LEARNACH.MOD
< prev
next >
Wrap
Text File
|
1987-07-27
|
4KB
|
109 lines
(*----------------------------------------------------------------------*)
(* Learn_A_Character --- Learn character for script *)
(*----------------------------------------------------------------------*)
PROCEDURE Learn_A_Character( Ch : CHAR );
(*----------------------------------------------------------------------*)
(* *)
(* Procedure: Learn_A_Character *)
(* *)
(* Purpose: Learn character for script in learn mode *)
(* *)
(* Calling Sequence: *)
(* *)
(* Learn_A_Character( Ch: CHAR ); *)
(* *)
(* Ch --- Character to be learned *)
(* *)
(*----------------------------------------------------------------------*)
VAR
L: INTEGER;
I: INTEGER;
J: INTEGER;
K: INTEGER;
BEGIN (* Learn_A_Character *)
(* Output stuff from remote system *)
IF ( ORD( Script_String_2[0] ) <> 0 ) THEN
(* Any waitstring after first in sequence *)
(* is spurious so don't generate it. *)
IF ( NOT Script_Wait_Generated ) THEN
BEGIN
L := ORD( Script_String_2[0] );
J := L;
K := 0;
(* If last chars are CR+LF, back up *)
(* in front of them. *)
IF ( L > 1 ) THEN
IF ( ( Script_String_2[L] = CHR( LF ) ) AND
( Script_String_2[L-1] = CHR( CR ) ) ) THEN
BEGIN
L := L - 2;
J := L;
END;
(* Loop until required number of lines *)
(* picked up. *)
REPEAT
I := J;
L := J;
(* Scan for CR and LFs *)
WHILE ( ( I > 1 ) AND ( NOT ( Script_String_2[I] IN [^M,^J] ) ) ) DO
I := PRED( I );
(* Adjust text pointer for next line *)
IF ( Script_String_2[I] = CHR( LF ) ) THEN
IF ( Script_String_2[I-1] = CHR( CR ) ) THEN
J := I - 2
ELSE
J := PRED( I )
ELSE
J := PRED( I );
(* Point after CR or LF *)
IF ( Script_String_2[I] IN [^M,^J] ) THEN
I := SUCC( I );
(* Generate waitstring if we got something *)
IF ( I > 0 ) THEN
IF ( ( L - I + 1 ) > 0 ) THEN
BEGIN
WRITELN( Script_File , 'WaitString "',
Write_Ctrls( SUBSTR( Script_String_2, I, L - I + 1 ) ), '"' );
K := SUCC( K );
END;
UNTIL ( ( K >= Script_Learn_Lines ) OR ( I <= 1 ) );
(* Indicate a waitstring has been generated *)
Script_Wait_Generated := TRUE;
END;
Script_String_2[0] := #0;
(* If CR, end of user input, generate SText *)
IF( ORD( Ch ) = CR ) THEN
BEGIN
WRITELN( Script_File , 'SText "', Script_String, '|"' );
Script_String[0] := #0;
Script_Wait_Generated := FALSE;
END
ELSE
IF ( ORD( Script_String[0] ) = 240 ) THEN
BEGIN
MOVE( Script_String[2], Script_String[1], 239 );
Script_String[240] := Ch;
END
ELSE
Script_String := Script_String + Ch;
END (* Learn_A_Character *);